# Table 3: Effect of Utility on Turnout in Concurrent Propositions


# 1. Load Packages ----

library(lfe)
library(stargazer)

# 2. Read in Data ----

load(file = "df_voxit_individual_analysis.RData")

# 3. Conduct Regressions ----
# 3.a Non-Standardized Coefficients ----
# Reg with Props>1
felm.props_all <- felm(turnout ~  utility_optc_sum + utility_optc_max +
                         prop_voxit + male + married + age + uni + knowledge  + 
                         leftright +
                         initiative + initiative_counter + referendum_fak + 
                         referendum_comp | 
                         canton_id + year | 0 | canton_id + datum_merge, 
                       data = voxit_individual[voxit_individual$prop_voxit>1,])
summary(felm.props_all)

# Reg with Props=2
felm.props2 <- felm(turnout ~ utility_optc_sum + utility_optc_max +
                      male + married + age + uni + knowledge  + leftright +
                      initiative + initiative_counter + referendum_fak + 
                      referendum_comp | 
                      canton_id + year | 0 | canton_id + datum_merge, 
                    data = voxit_individual[voxit_individual$prop_voxit==2,])
summary(felm.props2)

# Reg with Props=3
felm.props3 <- felm(turnout ~ utility_optc_sum + utility_optc_max +
                      male + married + age + uni + knowledge  + leftright +
                      initiative + initiative_counter + referendum_fak + 
                      referendum_comp | 
                      canton_id + year | 0 | canton_id + datum_merge, 
                    data = voxit_individual[voxit_individual$prop_voxit==3,])
summary(felm.props3)

# Reg with Props=4
felm.props4 <- felm(turnout ~ utility_optc_sum + utility_optc_max +
                      male + married + age + uni + knowledge + leftright +
                      initiative + initiative_counter + referendum_fak + 
                      referendum_comp | 
                      canton_id + year | 0 | canton_id + datum_merge, 
                    data = voxit_individual[voxit_individual$prop_voxit==4,])
summary(felm.props4)

# Reg with Props>=5
felm.props5 <- felm(turnout ~ utility_optc_sum + utility_optc_max +
                      male + married + age + uni + knowledge  + leftright +
                      initiative + initiative_counter + referendum_fak + 
                      referendum_comp | 
                      canton_id + year | 0 | canton_id + datum_merge, 
                    data = voxit_individual[voxit_individual$prop_voxit>=5,])
summary(felm.props5)


# Regression table
stargazer(felm.props_all, felm.props2, felm.props3, felm.props4, felm.props5,
          type = "latex",
          star.cutoffs = c(0.1, 0.05, 0.01),
          star.char = c("*", "**", "***"),
          summary=T,
          keep = c("^utility_optc_sum", "^utility_optc_max"),
          covariate.labels = c("U$^{sum}$", "U$^{max}$"),
          df = F,
          dep.var.caption="Dependent variable: Turnout",
          dep.var.labels.include=F,
          float = F, 
          omit.table.layout ="n",
          keep.stat = c("n"),
          add.lines = list(c("\\# of Propositions", ">1", "2", "3", "4", "5 or 6")),
          out = "Table3A.tex")


# 3.b Standardized Coefficients ----
# Standardize the utility measures
voxit_individual$utility_optc_sum1_norm <- 
  (voxit_individual$utility_optc_sum - 
     mean(voxit_individual[voxit_individual$prop_voxit>1,]$utility_optc_sum))/
  sd(voxit_individual[voxit_individual$prop_voxit>1,]$utility_optc_sum)

voxit_individual$utility_optc_max1_norm <- 
  (voxit_individual$utility_optc_max -
     mean(voxit_individual[voxit_individual$prop_voxit>1,]$utility_optc_max))/
  sd(voxit_individual[voxit_individual$prop_voxit>1,]$utility_optc_max)


# Reg with Props>1
felm.props_all_norm <- felm(turnout ~ utility_optc_sum1_norm + utility_optc_max1_norm +
                              prop_voxit + male + married + age + uni + knowledge  + 
                              leftright +
                              initiative + initiative_counter + referendum_fak + 
                              referendum_comp | 
                              canton_id + year | 0 | canton_id + datum_merge, 
                            data = voxit_individual[voxit_individual$prop_voxit>1,])
summary(felm.props_all_norm)

# Reg with Props=2
felm.p2_n <- felm(turnout ~ utility_optc_sum1_norm + utility_optc_max1_norm +
                    male + married + age + uni + knowledge  + leftright +
                    initiative + initiative_counter + referendum_fak + 
                    referendum_comp | 
                    canton_id + year | 0 | canton_id + datum_merge, 
                  data = voxit_individual[voxit_individual$prop_voxit==2,])
summary(felm.p2_n)

# Reg with Props=3
felm.p3_n <- felm(turnout ~ utility_optc_sum1_norm + utility_optc_max1_norm +
                    male + married + age + uni + knowledge  + leftright +
                    initiative + initiative_counter + referendum_fak + 
                    referendum_comp | 
                    canton_id + year | 0 | canton_id + datum_merge, 
                  data = voxit_individual[voxit_individual$prop_voxit==3,])
summary(felm.p3_n)

# Reg with Props=4
felm.p4_n <- felm(turnout ~ utility_optc_sum1_norm + utility_optc_max1_norm +
                    male + married + age + uni + knowledge  + leftright +
                    initiative + initiative_counter + referendum_fak + 
                    referendum_comp | 
                    canton_id + year | 0 | canton_id + datum_merge, 
                  data = voxit_individual[voxit_individual$prop_voxit==4,])
summary(felm.p4_n)

# Reg with Props>=5
felm.p5_n <- felm(turnout ~ utility_optc_sum1_norm + utility_optc_max1_norm +
                    male + married + age + uni + knowledge  + leftright +
                    initiative + initiative_counter + referendum_fak + 
                    referendum_comp | 
                    canton_id + year | 0 | canton_id + datum_merge, 
                  data = voxit_individual[voxit_individual$prop_voxit>=5,])
summary(felm.p5_n)


# Regression table
stargazer(felm.props_all_norm, felm.p2_n, felm.p3_n, felm.p4_n, felm.p5_n,
          type = "latex",
          star.cutoffs = c(0.1, 0.05, 0.01),
          star.char = c("*", "**", "***"),
          summary=T,
          keep = c("^utility_optc_sum", "^utility_optc_max"),
          covariate.labels = c("U$^{sum}$", "U$^{max}$"),
          df = F,
          dep.var.caption="Dependent variable: Turnout",
          dep.var.labels.include=F,
          float = F, 
          omit.table.layout ="n",
          keep.stat = c("n"),
          add.lines = list(c("\\# of Propositions", ">1", "2", "3", "4", "5 or 6")),
          out = "Table3B.tex")





